<?php
/**
 * ExcelTemplateController.php
 *
 * @copyright   2023 thingsworld.com.cn - All Rights Reserved
 * @link        http://thingsworld.com.cn/
 * @author      stiffer.chen <chenl@thingsworld.com.cn>
 * @created     2023-04-07 23:48:37
 * @modified    2023-04-07 23:48:37
 *
 */

namespace App\Http\Controllers;

use App\Services\ExcelTemplateService;

class ExcelTemplateController extends BaseModuleController
{
    /**
     * @OA\Get(
     *     path="/template/customer",
     *     tags={"Template"},
     *     summary="获取客户导入模板文件",
     *     description="获取客户导入模板文件",
     *     operationId="template_customer",
     *     security={{"bearerAuth":{}}},
     *     @OA\Response(response=200, description="请求成功"),
     *     @OA\Response(response=401,description="鉴权失败"),
     *     @OA\Response(response=422, description="请求异常")
     * )
     */
    public function customer()
    {
        try {
            $service = new ExcelTemplateService();
            $template = $service->customer();
            return message('获取成功', true, $template);
        } catch (\Exception $e) {
            return message($e->getMessage(), false);
        }
    }

    /**
     * @OA\Get(
     *     path="/template/product",
     *     tags={"Template"},
     *     summary="获取设备导入模板文件",
     *     description="获取设备导入模板文件",
     *     operationId="template_product",
     *     security={{"bearerAuth":{}}},
     *     @OA\Response(response=200, description="请求成功"),
     *     @OA\Response(response=401,description="鉴权失败"),
     *     @OA\Response(response=422, description="请求异常")
     * )
     */
    public function product()
    {
        try {
            $service = new ExcelTemplateService();
            $template = $service->product();
            return message('获取成功', true, $template);
        } catch (\Exception $e) {
            return message($e->getMessage(), false);
        }
    }

    /**
     * @OA\Get(
     *     path="/template/project_product",
     *     tags={"Template"},
     *     summary="获取项目设备导入模板文件",
     *     description="获取项目设备导入模板文件",
     *     operationId="template_product_product",
     *     security={{"bearerAuth":{}}},
     *     @OA\Response(response=200, description="请求成功"),
     *     @OA\Response(response=401,description="鉴权失败"),
     *     @OA\Response(response=422, description="请求异常")
     * )
     */
    public function project_product()
    {
        try {
            $service = new ExcelTemplateService();
            $template = $service->project_product();
            return message('获取成功', true, $template);
        } catch (\Exception $e) {
            return message($e->getMessage(), false);
        }
    }
}